package pers.flowerinsnow.minecraft.forge.shiftability.manager

import pers.flowerinsnow.minecraft.forge.shiftability.key.KeyBindingInstance
import pers.flowerinsnow.minecraft.forge.shiftability.listener.TickListener
import net.minecraft.client.settings.KeyBinding
import net.minecraftforge.fml.client.registry.ClientRegistry
import org.lwjgl.input.Keyboard
import java.lang.reflect.Modifier

class KeyManager {
    companion object {
        @KeyBindingInstance
        val TOGGLE = KeyBinding("key.shiftability.switch.fasttoggle", Keyboard.KEY_F7, "key.switch.category")

        fun registerKeys(cls: Class<*>) {
            cls.declaredFields.forEach { f ->
                if (f.isAnnotationPresent(KeyBindingInstance::class.java) && Modifier.isStatic(f.modifiers)) {
                    f.isAccessible = true
                    val k = f.get(null) as KeyBinding
                    ClientRegistry.registerKeyBinding(k)
                }
            }
        }
    }
}